home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gdevtrfx.c < prev    next >
C/C++ Source or Header  |  1993-05-13  |  2KB  |  70 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gdevtrfx.c */
  20. /* TruFax driver for Ghostscript. */
  21. /******
  22.  ****** Note: this file requires encode_l.o as supplied by TruFax.
  23.  ******/
  24. #include "gdevprn.h"
  25.  
  26. /* The device descriptor */
  27. #define X_DPI 204
  28. #define Y_DPI 196
  29. #define LINE_SIZE ((X_DPI * 85 / 10 + 7) / 8)    /* bytes per line */
  30. private dev_proc_print_page(trufax_print_page);
  31. gx_device_printer gs_trufax_device =
  32.   prn_device(prn_std_procs, "TruFax",
  33.     85,                /* width_10ths, 8.5" */
  34.     110,                /* height_10ths, 11" */
  35.     X_DPI, Y_DPI,
  36.     0,0,0,0,            /* margins */
  37.     1, trufax_print_page);
  38.  
  39. /* ------ Internal routines ------ */
  40.  
  41. private int
  42. trufax_print_page(gx_device_printer *pdev, FILE *prn_stream)
  43. {    char data[LINE_SIZE + 4];
  44.     int lnum;
  45.     int line_size;
  46.     char out_data[5 * 1734];    /* Sized according to TruFax */
  47.     int out_count;
  48.  
  49.     /* write TruFax header */
  50.     strcpy(out_data, "COSIf2");
  51.     out_data[6]=1;
  52.     out_data[7]=0;
  53.     out_data[8]=1;
  54.     out_data[9]=0;
  55.     fwrite(out_data, sizeof(char), 10, prn_stream);
  56.  
  57.     line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
  58.     for ( lnum = 0; lnum < pdev->height; lnum++ )
  59.        {
  60.         gdev_prn_copy_scan_lines(pdev, lnum, (byte *)data, line_size);
  61. /* 1728 = Sized according to TruFax */
  62.         out_count = encode_line(1728, data, out_data);
  63.         putc(out_count % 256, prn_stream);
  64.         putc(out_count / 256, prn_stream);
  65.         /* send the row */
  66.         fwrite(out_data, sizeof(char), out_count, prn_stream);
  67.        }
  68.     return 0;
  69. }
  70.